package Java练习.面向对象综合练习.基础;

public class girlFriendText {
    public static void main(String[] args) {
        girlFriend[] friends=new girlFriend[4];
        //定义4个女朋友对象
        girlFriend g1=new girlFriend();
        girlFriend g2=new girlFriend();
        girlFriend g3=new girlFriend();
        girlFriend g4=new girlFriend();
        //存放进数组
        friends[0]=g1;
        friends[1]=g2;
        friends[2]=g3;
        friends[3]=g4;
        //set_age
        g1.setAge(22);
        g2.setAge(19);
        g3.setAge(20);
        g4.setAge(23);
    //add
        int add=0;
        for (int i = 0; i < friends.length; i++) {
            add+=friends[i].getAge();

        }
        //计算平均age
        double avg_age=add*1.0/friends.length;
        //统计年龄比平均值低5的
        //记录有几个
        int count=0;
        for (int i = 0; i < friends.length; i++) {
            if(avg_age>friends[i].getAge()){
                count++;
                System.out.println(friends[i].getAge());
            }
        }
        System.out.println(count);
    }
}
